package com.ijiuchuang.jc_localization.view.fragment;


import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ijiuchuang.jc_localization.R;
import com.ijiuchuang.jc_localization.view.adapter.TechnologyFragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * A simple {@link Fragment} subclass.
 */
public class TechnologyFragment extends Fragment {

    @BindView(R.id.technology_tab_layout)
    TabLayout mTabLayout;
    @BindView(R.id.technology_view_pager)
    ViewPager mViewPager;

    private TechnologyFragmentPagerAdapter pagerAdapter;

    public TechnologyFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_technology, container, false);
        ButterKnife.bind(this, view);

        List<Fragment> fragmentList = new ArrayList<>();
        List<String> nameList = new ArrayList<>();

        fragmentList.add(new SolutionFragment());
        nameList.add("解决方案");
        fragmentList.add(new ProductFragment());
        nameList.add("智能硬件");
        pagerAdapter = new TechnologyFragmentPagerAdapter(getActivity().getSupportFragmentManager(), fragmentList, nameList);
        mViewPager.setAdapter(pagerAdapter);

        mTabLayout.setupWithViewPager(mViewPager);
        mTabLayout.setTabMode(TabLayout.MODE_FIXED);

        return view;
    }

}
